package com.genesis.yunnanji.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.genesis.yunnanji.R;
import com.genesis.yunnanji.utils.GenesisUtils;
import com.genesis.yunnanji.view.DataLoadingDialog;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;


/**
 * Created by Administrator on 2017/6/9.
 */

public abstract class BaseFragment extends Fragment {
    public Context context;
    public GenesisUtils genesisUtils;
    public DataLoadingDialog dialog;
    public View view;
    @ViewInject(R.layout.layout_shade)
    private View shade;
    private boolean injected = false;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        injected = true;
        context = this.getActivity();
        initUtils();

        dialog = new DataLoadingDialog(context);
        dialog.setCanceledOnTouchOutside(false);

        return x.view().inject(this, inflater, container);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (!injected) {
            x.view().inject(this, this.getView());
        }
        initView();
        setUpView();
    }


    private void initUtils() {
        genesisUtils = GenesisUtils.getIntance();
        genesisUtils.init(context);
    }

    protected abstract void initView();

    protected abstract void setUpView();


}
